<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
</head>
<body>
    <div id="app">
        <a href="" @click.prevent="comName='login'">登录</a>
        <a href="" @click.prevent="comName='register'">注册</a>

        <!-- Vue提供了 component，来展示对应名称的组件 -->
        <!-- is 属性，可用于来指定展示组件的名称 -->
        <component :is="comName"></component>
    </div>

    <script>
        Vue.component('login',Vue.extend({
            template: `<h3>登录组件</h3>`
        }));

        Vue.component('register',Vue.extend({
            template: `<h3>注册组件</h3>`
        }));

        var vm = new Vue({
            el: '#app',
            data: {
                // 当前 component 元素绑定的组件的名称
                comName: 'login'
            },
            methods:{

            }
        })
        
    </script>
</body>
</html>